package com.stock.stockana.requests;

import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.stock.stockana.beans.ResponseBean;
import com.stock.stockana.constants.NetWorkConstants;
import com.stock.stockana.events.network.GetVersionCodeEvent;
import com.stock.stockana.events.network.LoginInEvent;

import java.util.HashMap;
import java.util.Map;

import de.greenrobot.event.EventBus;

/**
 * Created by ljgsonx on 2016/1/24.
 */
public class GetVersionCode extends BaseStringRequest<GetVersionCode> {

    private final static String TAG = "GetVersionCode--->";

    private GetVersionCode() {
        super(Method.POST, NetWorkConstants.GET_VERSIONCODE_URL, listener, errorListener);
        Log.d(TAG, NetWorkConstants.GET_VERSIONCODE_URL);
    }

    static Response.Listener<String> listener = new Response.Listener<String>(){

        @Override
        public void onResponse(String response) {
            EventBus.getDefault().post(new GetVersionCodeEvent(NetWorkConstants.RESPONSE_CODE_OK,response));
        }
    };

    static Response.ErrorListener errorListener = new Response.ErrorListener(){

        @Override
        public void onErrorResponse(VolleyError error) {
            EventBus.getDefault().post(new GetVersionCodeEvent(NetWorkConstants.RESPONSE_CODE_NETWORK_ERROR,error.toString()));
        }
    };

    public static GetVersionCode build() {
        return new GetVersionCode();
    }


}
